package com.randis.dailyplanner.managers;

import java.util.List;
import java.util.UUID;

import javax.jdo.PersistenceManager;
import javax.jdo.Transaction;

import com.randis.dailyplanner.ServiceLocator;
import com.randis.dailyplanner.dao.UserDao;
import com.randis.dailyplanner.domain.User;

public class UserManager {

	ThreadLocal<User> currentUser = new ThreadLocal<User>();
	
	private UserDao dao = ServiceLocator.getInstance().getUserDao(); 
	
	public void setCurrentUser(User user) {
		currentUser.set(user);
	}

	public void clearCurrentUser() {
		currentUser.set(null);
	}

	public User getCurrentUser() {
		return currentUser.get();
	}

    public User getUser(String id) {
    	return dao.getUser(id);
    }

    public User findUser(String login) {
    	return dao.findUser(login);
    }

    public User saveUser(User user) {
    	return dao.saveUser(user);
    }

	public List<User> list() {
    	return dao.list();
    }

    public void deleteUser(String id) {
    	dao.deleteUser(id);
    }
}
